﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;

namespace GWEB.WebFrame.Models
{
    public class BaseCourse
    {
        public PageInfo Init()
        {
            PageInfo pg = new PageInfo();
            pg.Type = "BaseCourse";
            pg.Title = "";
            pg.AddText = "新增";
            pg.EditText = "";
            pg.LocateText = "查询";
            pg.SMenuId = "JX06";
            pg.FileUrl = "../Course/BaseCourse";
            pg.Condition = "";
            pg.TableName = "cu_sys_course";
            pg.KeyFieldName = "id";
            pg.PopEditHeight = 550;
            pg.PopEditWidth = 760;
            HttpSessionState session = System.Web.HttpContext.Current.Session;
            pg.dict = BasePage.getDict(session);
            pg.Sop = BasePage.Grant(session, pg.SMenuId);
            pg.Sop.DEL = false;
            pg.Sop.EDIT_htm = " ";
            pg.Tab.Add("课程", "LocatePara='';DataPageUrl='../Main/DataPageLay?type=BaseCourse';GoPage(1);");
            pg.Tab.Add("套餐", "LocatePara='';DataPageUrl='../Main/DataPageLay?type=MealCourse';GoPage(1);");
            string Url = "../Course/BaseCourse/UpdateState";//convert(varchar(10), cu_Account.id)
            string DelUrl = "../Course/BaseCourse/DelCourse";
            pg.Sql = @"select id,CourseName,StuNumber ,Dperiod,Remark,
case  when (StartMonth > '0') then convert(varchar,(StartMonth/12))+'年'+convert(varchar,(StartMonth%12))+'月'  END as StartMonth ,
case  when (EndMonth > '0') then convert(varchar,(EndMonth/12))+'年'+convert(varchar,(EndMonth%12))+'月'  END as EndMonth ,
case IsOrder when 0 then '不约' when 1 then '约' END as IsOrder ,
case IsTentative when 0 then '是' when 1 then '不是' END as IsTentative ,
case State when 0 then '开启' when 1 then '禁用' END as State ,
'<a class=''layui-btn layui-bg-red layui-btn-xs'' href=""javascript: Do(''" + DelUrl + @"'',{ id: '+ltrim(id)+',keyCode: GetKeyCode('''+ltrim(id)+''')})"" >删除</a>'  as link 
from  cu_sys_course where LeagueId=1 ";
            //  pg.Sql = "select * from cu_Account where LeagueId = 1"; cl.DictTypeID = "D18";
            ColumnInfo cl;
            cl = new ColumnInfo(); cl.FieldName = "CourseName"; cl.HeadText = "课程名称"; cl.Visible = true; cl.IsCondition = true; cl.ConditionPosition = 1; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "StuNumber"; cl.HeadText = "学生人数"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "Dperiod"; cl.HeadText = "扣课时"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "StartMonth"; cl.HeadText = "年龄段开始"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "EndMonth"; cl.HeadText = "年龄段结束"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "IsOrder"; cl.HeadText = "是否约课"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "IsTentative"; cl.HeadText = "是否试听"; cl.Visible = true; cl.Width = 80; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "Remark"; cl.HeadText = "摘要"; cl.Visible = true; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "State"; cl.HeadText = "状态"; cl.Visible = true; pg.AddColumn(cl);
            cl = new ColumnInfo(); cl.FieldName = "link"; cl.HeadText = "操作"; cl.IsSort = false; pg.AddColumn(cl);
            return pg;
        }

    }
}